package com.stone.starter.redis.config.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Map;

/**
 * redis 分片配置属性
 *
 * @author Mr_wenpan@163.com 2021-07-29
 */
@Data
@ConfigurationProperties(prefix = "stone.redis.sharding")
public class RedisShardingProperties {
    /**
     * 是否开启分片，默认为false
     */
    private boolean enabled;
    /**
     * redis实例信息，可连接多个Redis实例，key为配置的实例名称，value为每台实例信息
     */
    private Map<String, RedisConnector> instances;
    /**
     * redis资源池运行最小空闲的连接数
     */
    private int poolMinIdle;
    /**
     * redis资源池运行最大空闲的连接数
     */
    private int poolMaxIdle;
    /**
     * 最大等待时长
     */
    private long poolMaxWaitMillis;

    public RedisShardingProperties() {
        enabled = false;
    }

    /**
     * redis连接相关信息
     */
    @Data
    public static class RedisConnector {
        private String host;
        private int port;
        private String nodes;
        private String master;
        private String password;
        private long timeoutMillis;
        private int dbIndex;
    }
}
